package day3;

import java.util.Scanner;

public class Main1 {
    /**
     * kanan和高音
     * https://ac.nowcoder.com/acm/problem/26229
     */
    // 双指针 + 模拟
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for(int i = 0;i < n;i++) {
            arr[i] = in.nextInt();
        }

        int left = 0;
        int right = 0;
        int ret = 0;
        for(int i = 0;i < n;i++) {
            int j = i;
            while(j + 1 < n && arr[j + 1] - arr[j] <= 8) {
                j++;
            }
            ret = Math.max(ret,j - i + 1);
            i = j;
        }
        System.out.println(ret);
    }

    // 滑动窗口 + 模拟
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for(int i = 0;i < n;i++) {
            arr[i] = in.nextInt();
        }


        int ret = 0;
        for(int left = 0,right = 1;right < n;right++) {
            // 出窗口，进行判断是否符合，不符合就直接重新计算长度
            if(arr[right] - arr[right - 1] > 8) {
                left = right;
            }
            // 把每个符合的都进行更新
            ret = Math.max(ret,right - left + 1);
        }
        System.out.println(ret);
    }
}
